package com.gxz.job.quartz;

import org.quartz.*;

import java.util.Date;

@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class MyJob implements Job {
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
      /*  String name = context.getJobDetail().getJobDataMap().getString("name");
        System.out.println(name);*/
      /*  System.out.println(name);
        context.getJobDetail().getJobDataMap().put("name","itheima");
        System.out.println("任务被执行了" + new Date());*/
        System.out.println( Thread.currentThread().getName()+ "任务开始执行" + new Date());
        try {
            Thread.sleep(7000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println( Thread.currentThread().getName()+ "任务执行结束" + new Date());
    }
}
